<template>
	<orh-table>
		<span slot="option">
			<Button v-for="(item,index) in studentname" :key="index" style="margin-right:20px" type="primary" @click="childClick(item.student_base_id)">{{item.student_name}}</Button>
		</span>
		<student-basic-information-look slot="table" v-if="infoId" :infoId='infoId'></student-basic-information-look>
        <Spin slot="option" size="large" fix v-if="spinShow"></Spin>
	</orh-table>
</template>

<script>
  export default {
    components: {
        StudentBasicInformationLook: resolve => {require(['./../Public/StudentBasicInformationLook.vue'], resolve);},
    },
    name: "studentfilesmodule-myparentInformationdetail",
    data() {
		return {
			infoId:null,
			isShow:false,
			spinShow:false,
			show:null,
			studentname:[],
		}
    },
    methods: {
		/************************************************************
		 * 
		 * 获取数据
		 * 
		 ************************************************************/
		queryData(){
			this.infoId = null
			this.spinShow=true
			this.$http.get('api/parents/v1/parents/my_childrens').then(res=>{
				this.studentname=res.data
				if(this.studentname.length==1){
					this.childClick(this.studentname[0].student_base_id)
				}
				this.spinShow=false
			}).catch(err => {
				console.log(err);
				if(err.code && err.code==422) {
					this.$Message.error(err.message);
				}
				this.spinShow=false					                 
			})
		}, 

		/************************************************************
		 * 
		 * 点击孩子
		 * 
		 ************************************************************/
		childClick(infoId){
			this.infoId = infoId
		}, 

    },
    mounted() {
        this.queryData()
    }

  }
</script>
